package JUC_Advanced.chapter1_CompletableFuture;

/**
 * @Author: GuSongLiao
 * @Date: 2024/3/6 13:48
 * @Description: 判断线程是否为守护线程还是用户线程
 */
public class IsDaemon {

    public static void main(String[] args) {
        Thread t1 = new Thread(() -> {
            System.out.println(Thread.currentThread().getName() + "\t 开始运行，" +
                    (Thread.currentThread().isDaemon() ? "是守护线程" : "用户线程"));
        }, "t1");

        t1.setDaemon(true); // 手动设置为守护线程 此方法必须写在start()之前
        t1.start();
    }
}
